<?php
class Frames_Controller_Plugin_Auth extends  Frames_Controller_Plugin_Base
{
	public function dispatchLoopStartup( Zend_Controller_Request_Abstract $request )
	{
		$_view = new Zend_View( );
		$_view->lang = 'he';
		$_headMeta =  $_view->headMeta( );
		$_headMeta->appendHttpEquiv("Content-Type","text/html; charset=UTF-8");
		$_view->dbProfiler = Zend_Db_Table::getDefaultAdapter( )->getProfiler( );
		Zend_Controller_Action_HelperBroker::getStaticHelper( 'ViewRenderer' )->setView( $_view );
		$_auth = Zend_Auth::getInstance( );
		if(!$_auth->hasIdentity( )){
			$_view->hasIdentity = false;
			$request->setActionName( 'login' )
	          		  ->setControllerName( 'auth' );
		}else{
			$_view->hasIdentity = true;
			$_view->username = $_auth->getIdentity()->username;
		}
	}
}